<!--plugin hook--->
<?php if(isset($controller) && $controller == "bookhistory"){?>
<div class="filter">
    <style>
    .time{width:10% !important;}
    #submit,#export{vertical-align: top !important;}
    </style>
    <?php

    echo form_open('/auth/bookhistory/');
    if($this->session->userdata['group_id'] == 1){
        echo form_dropdown('userid', $this->bookhistory_model->getListUsers('id > 159 AND id < 175'), (isset($_POST['userid']))?$_POST['userid']:'','class="time" id="userid"');echo ' ';
        echo form_dropdown('payment_method', $this->bookhistory_model->getListPaymentMethod(), (isset($_POST['payment_method']))?$_POST['payment_method']:'','class="time"');echo ' ';
    }
        
    echo form_input(array('name' => 'customerID', 'id' => 'customerID', 'value' => (isset($_POST['customerID']))?$_POST['customerID']:'','class'=>'time','placeholder'=>'Mã khách hàng'));
    echo ' ';
    echo form_input(array('name' => 'booking_place_code', 'id' => 'booking_place_code', 'value' => (isset($_POST['booking_place_code']))?$_POST['booking_place_code']:'','class'=>'time','placeholder'=>$this->lang->line('booking_place_code')));
    echo ' ';
    echo form_input(array('name' => 'beginTime', 'id' => 'datepicker1', 'value' => (isset($_POST['beginTime']))?$_POST['beginTime']:'','class'=>'time','placeholder'=>'Chọn ngày bắt đầu'));
    echo ' ';
    echo form_input(array('name' => 'endTime', 'id' => 'datepicker2', 'value' => (isset($_POST['endTime']))?$_POST['endTime']:'','class'=>'time','placeholder'=>'Chọn ngày kết thúc'));
    echo ' ';
    echo form_button(array('id' => 'submit', 'value' => 'filter', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('search'),'class' => 'btn btn-primary'));
    echo ' ';
    echo form_button(array('id' => 'export', 'value' => 'export', 'name' => 'submit', 'content' => $this->lang->line('export'),'class' => 'btn btn-danger'));
    echo '<span id="simple-msg-submit"></span>';
    echo form_close();
    ?>
</div>
<div id="simple-content" style="display: hidden"></div>
<script>
$("#export").on('click',function(e)
{
    if($("#customerID").val() == "" && $("#datepicker1").val() == "" && $("#datepicker2").val() == "" && $("#userid").val() == "" && $("#payment_method").val() == ""){
        alert("Vui lòng điền ít nhất 1 thông tin cần xử lí");
        return false;
    }
    $("#simple-msg-submit").html("<img src='<?php echo base_url().'static/templates/frontend/home/images/';?>loading.gif'/>");
    setTimeout(function () {
        $.ajax(
            {
                url : '/auth/bookhistory/export',
                type: "POST",
                data : { customerID: $("#customerID").val(), beginTime: $("#datepicker1").val(), endTime: $("#datepicker2").val(), submit: $("#export").val(), userid: $("#userid").val() },
                cache: true,
                beforeSend: function(){

                },
                success:function(data) 
                {
                        $("#simple-msg-submit").hide();
                        $("#simple-content").html(data);
                        $("#data-table-export").hide();
                        var dt = new Date();
                        var day = dt.getDate();
                        var month = dt.getMonth() + 1;
                        var year = dt.getFullYear();
                        var hour = dt.getHours();
                        var mins = dt.getMinutes();
                        var postfix = day + "." + month + "." + year + "_" + hour + "." + mins;
                        //creating a temporary HTML link element (they support setting file names)
                        var a = document.createElement('a');
                        //getting data from our div that contains the HTML table
                        var data_type = 'data:application/vnd.ms-excel';
                        var table_div = document.getElementById('data-table-export');
                        var table_html = table_div.outerHTML.replace(/ /g, '%20');
                        a.href = data_type + ', ' + table_html;
                        //setting the file name
                        a.download = 'exported_table_' + postfix + '.xls';
                        //triggering the function
                        a.click();
                        //just in case, prevent default behaviour
                        e.preventDefault();
                },
                error: function() 
                {
                    $("#simple-msg-submit").html('Có lỗi xảy ra! Contact Admin!');
                }
            });
    }, 1000);
    e.preventDefault();	//STOP default action
});
</script>
<?php }?>

<!--plugin hook for paymentAtHome--->
<?php if(isset($controller) && $controller == "paymentAtHome"){?>
<div class="filter">
    <style>
    .time{width:15% !important;}
    #submit,#search{vertical-align: top !important;}
    </style>
   <?php

    echo form_open('/auth/paymentAtHome/');
    echo form_dropdown('ticketWorkers', $this->paymentAtHome_model->getListTicketWorkers(), (isset($_POST['ticketWorkers']))?$_POST['ticketWorkers']:'','class="time"');
    echo ' ';
    echo form_dropdown('province', $this->paymentAtHome_model->getListProvince(), (isset($_POST['province']))?$_POST['province']:'','class="time"');
    echo ' ';
    echo form_dropdown('district', $this->paymentAtHome_model->getListDistrict(), (isset($_POST['district']))?$_POST['district']:'','class="time"');
    echo ' ';
    echo form_dropdown('status', array(''=>'Trạng thái giao vé', '0'=>'Chưa giao','1'=>'Đã giao'), (isset($_POST['status']))?$_POST['status']:'','class="time"');
    echo ' ';
    echo form_button(array('id' => 'submit', 'value' => 'search', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('search'),'class' => 'btn btn-primary'));
    echo '<span id="simple-msg-submit"></span>';
    echo form_close();
    ?>
</div>
<div id="simple-content" style="display: hidden"></div>
<?php } ?>

<!--plugin hook for paymentAtHome--->
<?php if(isset($controller) && $controller == "bookingStatus"){?>
<div class="filter">
    <style>
    .time{width:15% !important;}
    #submit,#search{vertical-align: top !important;}
    </style>
   <?php

    echo form_open('/auth/bookingStatus/');
    echo form_input(array('name' => 'h_searchCustomersPhone', 'id' => 'h_searchCustomersPhone', 'value' => (isset($_POST['h_searchCustomersPhone']))?$_POST['h_searchCustomersPhone']:'','class'=>'time','placeholder'=>$this->lang->line('searchCustomersPhone')));
    echo ' ';
    echo form_input(array('name' => 'h_booking_place_code', 'id' => 'h_booking_place_code', 'value' => (isset($_POST['h_booking_place_code']))?$_POST['h_booking_place_code']:'','class'=>'time','placeholder'=>$this->lang->line('booking_place_code')));
    echo ' ';
    echo form_input(array('name' => 'h_beginTime', 'id' => 'datepicker1', 'value' => (isset($_POST['h_beginTime']))?$_POST['h_beginTime']:'','class'=>'time','placeholder'=>$this->lang->line('beginTime')));
    echo ' ';
    echo form_input(array('name' => 'h_endTime', 'id' => 'datepicker2', 'value' => (isset($_POST['h_endTime']))?$_POST['h_endTime']:'','class'=>'time','placeholder'=>$this->lang->line('endTime')));
    echo ' ';
    echo form_button(array('id' => 'submit', 'value' => 'search', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('search'),'class' => 'btn btn-primary'));
    echo '<span id="simple-msg-submit"></span>';
    echo form_close();
    ?>
</div>
<div id="simple-content" style="display: hidden"></div>
<?php } ?>

<!--plugin hook for listcustomers--->
<?php if(isset($controller) && $controller == "listcustomers"){?>
<div class="filter">
    <style>
    .time{width:15% !important;}
    #submit,#search{vertical-align: top !important;}
    </style>
   <?php

    echo form_open('/auth/listcustomers/');
    echo form_input(array('name' => 'customersName', 'id' => 'customersName', 'value' => (isset($_POST['customersName']))?$_POST['customersName']:'','class'=>'time','placeholder'=>$this->lang->line('searchCustomersName')));
    echo ' ';
    echo form_input(array('name' => 'phone', 'id' => 'phone', 'value' => (isset($_POST['phone']))?$_POST['phone']:'','class'=>'time','placeholder'=>$this->lang->line('searchCustomersPhone')));
    echo ' ';
    echo form_button(array('id' => 'submit', 'value' => 'search', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('search'),'class' => 'btn btn-primary'));
    echo '<span id="simple-msg-submit"></span>';
    echo form_close();
    ?>
</div>
<div id="simple-content" style="display: hidden"></div>
<?php } ?>

<!--plugin hook for listcustomers--->
<?php if(isset($controller) && $controller == "listcustomersDebts"){?>
<div class="filter">
    <style>
    .time{width:15% !important;}
    #submit,#search{vertical-align: top !important;}
    </style>
   <?php

    echo form_open('/auth/listcustomersDebts/');
    echo form_input(array('name' => 'customersName', 'id' => 'customersName', 'value' => (isset($_POST['customersName']))?$_POST['customersName']:'','class'=>'time','placeholder'=>$this->lang->line('searchCustomersName')));
    echo ' ';
    echo form_input(array('name' => 'phone', 'id' => 'phone', 'value' => (isset($_POST['phone']))?$_POST['phone']:'','class'=>'time','placeholder'=>$this->lang->line('searchCustomersPhone')));
    echo ' ';
    echo form_button(array('id' => 'submit', 'value' => 'search', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('search'),'class' => 'btn btn-primary'));
    echo '<span id="simple-msg-submit"></span>';
    echo form_close();
    ?>
</div>
<div id="simple-content" style="display: hidden"></div>
<?php } ?>

<!--plugin hook for voucher--->
<?php if(isset($controller) && $controller == "voucher"){?>
<div class="filter">
    <style>
    .time{width:15% !important;}
    #submit,#search{vertical-align: top !important;}
    </style>
   <?php

    echo form_open('/auth/voucher/');
    echo form_input(array('name' => 'customersName', 'id' => 'customersName', 'value' => (isset($_POST['customersName']))?$_POST['customersName']:'','class'=>'time','placeholder'=>$this->lang->line('customer')));
    echo ' ';
    echo form_input(array('name' => 'booking_place_code', 'id' => 'phone', 'value' => (isset($_POST['booking_place_code']))?$_POST['booking_place_code']:'','class'=>'time','placeholder'=>$this->lang->line('booking_place_code')));
    echo ' ';
    echo form_dropdown('payment_method', $this->voucher_model->getListPaymentMethod(), (isset($_POST['payment_method']))?$_POST['payment_method']:'','class="time"');echo ' ';
    echo form_button(array('id' => 'submit', 'value' => 'search', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('search'),'class' => 'btn btn-primary'));
    echo '<span id="simple-msg-submit"></span>';
    echo form_close();
    ?>
</div>
<div id="simple-content" style="display: hidden"></div>
<?php } ?>


<!--plugin hook for voucher--->
<?php if(isset($controller) && $controller == "voucherArise"){?>
<div class="filter">
    <style>
    .time{width:10% !important;}
    #submit,#search,#export{vertical-align: top !important;}
    </style>
   <?php
    echo form_open('/auth/voucherArise/');
    echo form_dropdown('payment_method', $this->voucherArise_model->getListPaymentMethod(), (isset($_POST['payment_method']))?$_POST['payment_method']:'','class="time" id="payment_method"');echo ' ';
    echo ' ';
    echo form_input(array('name' => 'customersName', 'id' => 'customersName', 'value' => (isset($_POST['customersName']))?$_POST['customersName']:'','class'=>'time','placeholder'=>$this->lang->line('customer')));
    echo ' ';
    echo form_input(array('name' => 'booking_place_code', 'id' => 'booking_place_code', 'value' => (isset($_POST['booking_place_code']))?$_POST['booking_place_code']:'','class'=>'time','placeholder'=>$this->lang->line('booking_place_code')));
    echo ' ';
    echo form_input(array('name' => 'vh_beginTime', 'id' => 'datepicker1', 'value' => (isset($_POST['vh_beginTime']))?$_POST['vh_beginTime']:'','class'=>'time','placeholder'=>$this->lang->line('beginTime')));
    echo ' ';
    echo form_input(array('name' => 'vh_endTime', 'id' => 'datepicker2', 'value' => (isset($_POST['vh_endTime']))?$_POST['vh_endTime']:'','class'=>'time','placeholder'=>$this->lang->line('endTime')));
    echo ' ';
    echo form_button(array('id' => 'submit', 'value' => 'search', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('search'),'class' => 'btn btn-primary'));
    echo ' ';
    echo form_button(array('id' => 'export', 'value' => 'export', 'name' => 'submit', 'content' => $this->lang->line('export'),'class' => 'btn btn-danger'));
    echo '<span id="simple-msg-submit"></span>';
    echo form_close();
    ?>
</div>
<div id="simple-content" style="display: hidden"></div>
<script>
$("#export").on('click',function(e)
{
    if($("#customerID").val() == "" && $("#datepicker1").val() == "" && $("#datepicker2").val() == "" && $("#userid").val() == "" && $("#payment_method").val() == ""){
        alert("Vui lòng điền ít nhất 1 thông tin cần xử lí");
        return false;
    }
    $("#simple-msg-submit").html("<img src='<?php echo base_url().'static/templates/frontend/home/images/';?>loading.gif'/>");
    setTimeout(function () {
        $.ajax(
            {
                url : '/auth/voucherArise/export',
                type: "POST",
                data : { payment_method: $("#payment_method").val(), beginTime: $("#datepicker1").val(), endTime: $("#datepicker2").val(), 
                            customersName: $("#customersName").val(),booking_place_code: $("#booking_place_code").val(),
                            submit: $("#export").val()},
                cache: true,
                beforeSend: function(){

                },
                success:function(data) 
                {
                        $("#simple-msg-submit").hide();
                        $("#simple-content").html(data);
                        $("#data-table-export").hide();
                        var dt = new Date();
                        var day = dt.getDate();
                        var month = dt.getMonth() + 1;
                        var year = dt.getFullYear();
                        var hour = dt.getHours();
                        var mins = dt.getMinutes();
                        var postfix = day + "." + month + "." + year + "_" + hour + "." + mins;
                        //creating a temporary HTML link element (they support setting file names)
                        var a = document.createElement('a');
                        //getting data from our div that contains the HTML table
                        var data_type = 'data:application/vnd.ms-excel';
                        var table_div = document.getElementById('data-table-export');
                        var table_html = table_div.outerHTML.replace(/ /g, '%20');
                        a.href = data_type + ', ' + table_html;
                        //setting the file name
                        a.download = 'exported_table_' + postfix + '.xls';
                        //triggering the function
                        a.click();
                        //just in case, prevent default behaviour
                        e.preventDefault();
                },
                error: function() 
                {
                    $("#simple-msg-submit").html('Có lỗi xảy ra! Contact Admin!');
                }
            });
    }, 1000);
    e.preventDefault();	//STOP default action
});
</script>
<?php } ?>

<!--plugin hook for bookingDebts--->
<?php if(isset($controller) && $controller == "bookingDebts"){?>
<div class="filter">
    <style>
    .time{width:15% !important;}
    #submit,#search{vertical-align: top !important;}
    </style>
   <?php
    echo form_open('/auth/bookingDebts/');
    echo form_input(array('name' => 'h_booking_place_code', 'id' => 'h_booking_place_code', 'value' => (isset($_POST['h_booking_place_code']))?$_POST['h_booking_place_code']:'','class'=>'time','placeholder'=>$this->lang->line('booking_place_code')));
    echo ' ';
    echo form_input(array('name' => 'h_beginTime', 'id' => 'datepicker1', 'value' => (isset($_POST['h_beginTime']))?$_POST['h_beginTime']:'','class'=>'time','placeholder'=>$this->lang->line('beginTime')));
    echo ' ';
    echo form_input(array('name' => 'h_endTime', 'id' => 'datepicker2', 'value' => (isset($_POST['h_endTime']))?$_POST['h_endTime']:'','class'=>'time','placeholder'=>$this->lang->line('endTime')));
    echo ' ';
    echo form_button(array('id' => 'submit', 'value' => 'search', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('search'),'class' => 'btn btn-primary'));
    echo '<span id="simple-msg-submit"></span>';
    echo form_close();
    ?>
</div>
<div id="simple-content" style="display: hidden"></div>
<?php } ?>

<!--plugin hook for telecom--->
<?php if(isset($controller) && $controller == "telecom"){?>
<div class="filter">
    <style>
    .time{width:15% !important;}
    #submit,#search{vertical-align: top !important;}
    </style>
   <?php
    echo form_open('/auth/telecom/');
    echo form_input(array('name' => 'phone', 'id' => 'phone', 'value' => (isset($_POST['phone']))?$_POST['phone']:'','class'=>'time','placeholder'=>$this->lang->line('phone')));
    echo ' ';
    echo form_button(array('id' => 'submit', 'value' => 'search', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('search'),'class' => 'btn btn-primary'));
    echo '<span id="simple-msg-submit"></span>';
    echo form_close();
    ?>
</div>
<div id="simple-content" style="display: hidden"></div>
<?php } ?>

<!--plugin hook for voucher--->
<?php if(isset($controller) && $controller == "voucherHistory"){?>
<div class="filter">
    <style>
    .time{width:15% !important;}
    #submit,#search{vertical-align: top !important;}
    </style>
   <?php

    echo form_open('/auth/voucherHistory/');
    echo form_input(array('name' => 'customersName', 'id' => 'customersName', 'value' => (isset($_POST['customersName']))?$_POST['customersName']:'','class'=>'time','placeholder'=>$this->lang->line('customer')));
    echo ' ';
    echo form_input(array('name' => 'booking_place_code', 'id' => 'phone', 'value' => (isset($_POST['booking_place_code']))?$_POST['booking_place_code']:'','class'=>'time','placeholder'=>$this->lang->line('booking_place_code')));
    echo ' ';
    echo form_dropdown('payment_method', $this->voucherHistory_model->getListPaymentMethod(), (isset($_POST['payment_method']))?$_POST['payment_method']:'','class="time"');echo ' ';
    echo form_button(array('id' => 'submit', 'value' => 'search', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('search'),'class' => 'btn btn-primary'));
    echo '<span id="simple-msg-submit"></span>';
    echo form_close();
    ?>
</div>
<div id="simple-content" style="display: hidden"></div>
<?php } ?>

<!--plugin hook for paymentAir--->
<?php if(isset($controller) && $controller == "paymentAir"){?>
<div class="filter">
    <style>
    .time{width:15% !important;}
    #submit,#search{vertical-align: top !important;}
    </style>
   <?php

    echo form_open('/auth/paymentAir/');
    echo form_input(array('name' => 'air_booking_place_code', 'id' => 'air_booking_place_code', 'value' => (isset($_POST['air_booking_place_code']))?$_POST['air_booking_place_code']:'','class'=>'time','placeholder'=>$this->lang->line('booking_place_code')));
    echo ' ';
    echo form_input(array('name' => 'air_customersName', 'id' => 'air_customersName', 'value' => (isset($_POST['air_customersName']))?$_POST['air_customersName']:'','class'=>'time','placeholder'=>$this->lang->line('customersName')));
    echo ' ';
    echo form_button(array('id' => 'submit', 'value' => 'search', 'name' => 'submit', 'type' => 'submit', 'content' => $this->lang->line('search'),'class' => 'btn btn-primary'));
    echo '<span id="simple-msg-submit"></span>';
    echo form_close();
    ?>
</div>
<div id="simple-content" style="display: hidden"></div>
<?php } ?>